<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<%@page import="com.framework.utils.ConfigUtil"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>信息编辑窗体</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <%--<link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">--%>
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

   <%-- <link href="${ctxStatic}/plugins/h+/css/font-awesome.min.css" rel="stylesheet">--%>
    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <style>
        .dtupload>img{
            width: 54px;
            padding-left: 39px;
            padding-top: 16px;
        }
        .dtupload>a{
            color: #268eff;
            font-size: 12px;
            position: relative;
            left: 26px;
            top: 10px;
        }.dtupload>a:hover,
         .shoplogo>a:hover{
             color:#F93;
         }.upload_pic {
              height: 70px;
              width:70px;
              position: relative;
              cursor: pointer;
              color: #ccbe9e;
              background: #fff;
              overflow: hidden;
              display: inline-block;
              *display: inline;
              *zoom: 1;
          }
        .upload_pic input {
            position: absolute;
            height:100%;
            width:100%;
            right: 0;
            top: 0;
            opacity: 0;
            filter: alpha(opacity=0);
            cursor: pointer
        }
        .upload_pic:hover {
            color: #ccbe9e;
            background: #fff;
            text-decoration: none
        }
    </style>
</head>

<div class="wrapper wrapper-content">
    <div class="panel-body">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form onsubmit="return  false" class="form-horizontal" id="signupForm">
                        <input name="pwxgoodsGroup.id" type="hidden" value="${PwxgoodsGroup.id}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">分组名称：</label>
                            <div class="col-sm-8">
                                <input id="pwxgoodsGroup_name" name="pwxgoodsGroup.name" value="${PwxgoodsGroup.name}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否显示：</label>
                            <div class="col-sm-3">
                                <div class="switch">
                                    <div class="onoffswitch">
                                        <input type="checkbox" class="onoffswitch-checkbox" id="wxgoodsGroup_state" name="pwxgoodsGroup.state">
                                        <label class="onoffswitch-label" for="wxgoodsGroup_state">
                                            <span class="onoffswitch-inner"></span>
                                            <span class="onoffswitch-switch"></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">默认图片：</label>
                            <div class="col-sm-4">
                                <!--上传logo-->
                                <div class="dtupload">
                                    <a href="javascript:" class="upload_pic" style="height:80px;">
                                        <img  src="<%=ConfigUtil.get("OSSURL")%>${PwxgoodsGroup.defImgUrl}" width="100%"/>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">自定义图片：</label>
                            <div class="col-sm-4">
                                <!--上传logo-->
                                <div class="dtupload">
                                    <a href="javascript:" class="upload_pic" style="height:80px;"><input type="file" name="fileToUpload" id="fileToUpload1" onChange="uploadFile('fileToUpload1','imgUpdate','customImgId');">
                                        <img  id="imgUpdate" src="<%=ConfigUtil.get("OSSURL")%>${PwxgoodsGroup.customImgUrl}" width="100%"/>
                                        <input type="hidden" id="customImgId" value="${PwxgoodsGroup.customImg}" name="pwxgoodsGroup.customImg">
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否使用自定义图片：</label>
                            <div class="col-sm-3">
                                <div class="switch">
                                    <div class="onoffswitch">
                                        <input type="checkbox" class="onoffswitch-checkbox" id="wxgoodsGroup_isCustom" name="pwxgoodsGroup.isCustom">
                                        <label class="onoffswitch-label" for="wxgoodsGroup_isCustom">
                                            <span class="onoffswitch-inner"></span>
                                            <span class="onoffswitch-switch"></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="col-sm-8">
                                <input  onblur="checkNum(this);" style="width:80px" name="pwxgoodsGroup.sort" value="${PwxgoodsGroup.sort}" class="form-control" type="number">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">备注：</label>
                            <div class="col-sm-8">
                                <input name="pwxgoodsGroup.note" value="${PwxgoodsGroup.note}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" onclick="doSubmit();">提交</button>
                                <button id="btn_close"  class="btn btn-primary" type="button">关闭</button>
                              <%--  <button id="transmit"  class="btn btn-primary" type="button">给父页面传值</button>--%>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/validate/jquery.validate.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/validate/messages_zh.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/demo/form-validate-demo.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/plugins/h+/js/plugins/layer2.4/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/ajaxfileupload.js"></script>

<script>
    $(function(){
        if("${PwxgoodsGroup.state}"=='0'){
            $("#wxgoodsGroup_state").prop("checked",true)
        }else{
            $("#wxgoodsGroup_state").prop("checked",false);
        }
        if("${PwxgoodsGroup.isCustom}"=='1'){
            $("#wxgoodsGroup_isCustom").prop("checked",true)
        }else{
            $("#wxgoodsGroup_isCustom").prop("checked",false);
        }

    });
    function  checkNum(obj) {
        if(obj.value<0)
        {alert("请正确输入排序数字!");
            obj.value=0;}
    }
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引


    //关闭iframe
    $('#btn_close').click(function(){
        parent.layer.close(index);
    });


function doSubmit()
{
    var name=$("#pwxgoodsGroup_name").val();


    var isOk=true;
    if(name==null||name==undefined||name==''){alert("请输入分组名称");isOk= false;}
if(isOk){
    $.ajax( {
        url:'${pageContext.request.contextPath}/pic/doUpdateGoodsGroup.ac',// 跳转到 action
        data:$("#signupForm").serialize(),
        type:'post',
        cache:false,
        dataType:'json',
        success:function(data) {
           if(data=="success")
           {
               alert("操作成功！");
               parent.layer.close(index);
           }else
           {
               alert(data);
           }
        },
        error : function() {
            alert("操作失败！");
        }
    });
}
}

    var picPath='<%=ConfigUtil.get("OSSURL")%>';

function uploadFile(obj,id,picId){//上传图片
    var labid = "";
    //var detailId = $("#detailId").val();
    //$("#"+id).css("background","url(${pageContext.request.contextPath}/resources/assets/images/waiting.gif) no-repeat 0 0/100% 100%");
    $.ajaxFileUpload({
        url: '${pageContext.request.contextPath}/common/doUploadFile.ac',
        secureuri: false,
        type:'post',
        fileElementId: obj,
        dataType: 'text',
        success: function(data, status) {
            var img=JSON.parse(data);
            $("#"+id).attr("src",picPath+img.path);
            $("#"+picId).val(img.picId);

        },
        error: function(data, status, e) {
            alert(e);
        }
    });
}

</script>

</body>

</html>

